package com.itheima.test2;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        /*
            张三,男,20,79.5
            李四,女,21,80.2
            王五,男,22,77.9
            周六,男,20,55.8
		    赵七,女,21,99.9
         */
        Student s1 = new Student("张三", "男", 20, 79.5);
        Student s2 = new Student("李四", "女", 21, 80.2);
        Student s3 = new Student("王五", "男", 22, 77.9);
        Student s4 = new Student("周六", "男", 20, 55.8);
        Student s5 = new Student("赵七", "女", 21, 99.9);
        ArrayList<Student> students = new ArrayList<>();
        students.add(s1);
        students.add(s2);
        students.add(s3);
        students.add(s4);
        students.add(s5);
        BigDecimal sum = new BigDecimal("0");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            BigDecimal score = new BigDecimal("" + s.getScore());
            sum=sum.add(score);
        }
        BigDecimal count = new BigDecimal("" + students.size());
        BigDecimal avg = sum.divide(count,2, RoundingMode.FLOOR);
        System.out.println(avg);
    }
}
